using System.IO.Ports;

namespace Sensor.SerialPorts;

public class SerialPortHelp
{
    public static List<string> GetPortNames()
    {
        return [.. SerialPort.GetPortNames()];
    }

    public static Parity GetParity(string emp)
    {
        var parity = emp switch
        {
            "None" => Parity.None,
            "Odd" => Parity.Odd,
            "Even" => Parity.Even,
            _ => Parity.None,
        };
        return parity;
    }

    public static StopBits GetStopBits(string emp)
    {
        var stopBits = emp switch
        {
            "One" => StopBits.One,
            "Two" => StopBits.Two,
            "OnePointFive" => StopBits.OnePointFive,
            _ => StopBits.None,
        };
        return stopBits;
    }
}
